package com.iuie.ns.devtools.element;

import java.util.List;

import com.iuie.ns.devtools.to.DevBodyTO;
import com.iuie.ns.frame.utils.StringUtils;

public class ResultMapResultElement extends DevElement {
	
	private DevBodyTO body;

	
	public ResultMapResultElement(DevBodyTO body) {
		this.body = body;
	}

	@Override
	protected String getPrefix() {
		StringBuilder sb = new StringBuilder(12);
		sb.append("\t\t");
		if (body.isIdAttribute()) {
			sb.append("<id column=\"");
		} else {
			sb.append("<result column=\"");
		}
		String fieldType = body.getFieldType();
		if (StringUtils.equals(body.getFieldType(), "DATE")) {
			fieldType = "TIMESTAMP";
		}
		sb.append(body.getFieldName())
			.append("\" property=\"")
			.append(body.getAttributeName())
			.append("\" jdbcType=\"")
			.append(fieldType)
			.append("\"/>\n");
		return sb.toString();
	}

	@Override
	protected String getSuffix() {
		return null;
	}

	@Override
	protected List<DevElement> getChildren() {
		return null;
	}

}
